*12345678901234567890123456789012345678901234567890123456789012345678901234567890

capture log close
clear
clear matrix
set mem 500m
set more off

#delimit ;

log using "C:\Documents and Settings\James\Desktop\my dropbox\PTAs\BacciniData\bacciniACLP.log", 
replace;

*	************************************************************************ *;
* 	File-Name: bacciniACLP.do												 *;
*	Date:  12/20/10															 *;
*	Author: 	James Hollyer                                                *;
*	Purpose:   To establish whether the relationships in Hollyer and 		 *;
*	Rosendorff	continue to hold when the ACLP democracy measure is used in  *;
*	place of polity.													 	 *;
*	Data Input: baccini_survival2.dta, CheibubGandhiVreeland.dta			 *;
*	************************************************************************ *;

use "c:\documents and settings\james\desktop\my dropbox\PTAs\BacciniData\baccini_survival2.dta";

sort ccode year;

save "c:\documents and settings\james\desktop\my dropbox\PTAs\BacciniData\baccini_survival2.dta",
replace;

clear;

use "c:\documents and settings\james\desktop\my dropbox\PTAs\BacciniData\CheibubGandhiVreeland.dta";

rename cowcode ccode;

drop if year<1995|year>2004;
drop if ccode==.;

*Germany's ccode does not match in the two datasets.;
replace ccode=260 if ccode==255;

sort ccode year;

merge 1:m ccode year using "c:\documents and settings\james\desktop\my dropbox\PTAs\BacciniData\baccini_survival2.dta";

*No using data fails to be matched.;
drop if _merge~=3;
drop _merge;

stset endobs, id(leadid) fail(fail==1) origin(eindate) enter(time mdy(1,1,1995))
scale(365.25);

*	************************************************************************ *;
*	The following will generate a variable 									 *;
*	log_num_pta_sign=ln(num_pta_lead_sign+1)								 *;
*	************************************************************************ *;

gen log_num_pta_sign=.;
replace log_num_pta_sign=ln(num_pta_lead_sign+1);

*	************************************************************************ *;
*	The following will estimate models equivalent to those used in the paper *;
*	using the ACLP democracy score in place of Polity.						 *;
*	************************************************************************ *;

gen pta_sign_dem = pta_lead_sign*democracy;
gen pta_num_dem = log_num_pta_sign*democracy;

stcox  log_num_pta_sign democracy pta_num_dem rgdpch openk grgdpch, 
tvc(log_num_pta_sign democracy pta_num_dem) shared(ccode);

stcox  log_num_pta_sign democracy pta_num_dem rgdpch openk grgdpch, shared(ccode);

sum log_num_pta_sign;

local max_log_pta=r(max);
local max_pta_min_ACLP=0;
local max_pta_max_ACLP=`max_log_pta';

stcurve, hazard at1(democracy=0  log_num_pta_sign=0  pta_num_dem=0) 
at2(democracy=0 log_num_pta_sign=0.693 pta_num_dem=-0) 
at3(democracy=0 log_num_pta_sign=`max_log_pta' pta_num_dem = `max_pta_min_ACLP')
graphregion(fcolor(white)) ytitle(Hazard Rate) xtitle(Years in Office) 
scheme(s2mono) legend(label(1 No PTA) label(2 One PTA) label(3 Max PTAs)) 
name(minACLP, replace) subtitle(Autocracies);

stcurve, hazard at1(democracy=1  log_num_pta_sign=0  pta_num_dem=0) 
at2(democracy=1 log_num_pta_sign=0.693 pta_num_dem=.693) 
at3(democracy=1 log_num_pta_sign=`max_log_pta' pta_num_dem =`max_pta_max_ACLP')
graphregion(fcolor(white)) ytitle(Hazard Rate) xtitle(Years in Office) 
scheme(s2mono) legend(label(1 No PTA) label(2 One PTA) label(3 Max PTAs)) 
name(maxACLP, replace) subtitle(Democracies);

graph combine minACLP maxACLP, ycommon graphregion(fcolor(white))
title(Estimated Hazard Rates);

stcox  log_num_pta_sign democracy rgdpch openk grgdpch, 
tvc(log_num_pta_sign democracy) shared(ccode);

stcox  log_num_pta_sign democracy rgdpch openk grgdpch, shared(ccode);


*	************************************************************************ *;
*	The following will close the log file.									 *;
*	************************************************************************ *;

log close;
